<%@ page language="java" import="java.util.*,ct.zxd.db.*" pageEncoding="utf-8"
contentType="text/html"%>

<html lang="zh-cn">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
	<meta name="renderer" content="webkit">
	<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
	<title></title>
	<link rel="stylesheet" href="css/pintuer.css">
	<link rel="stylesheet" href="css/admin.css">
	<script src="js/jquery.js"></script>
	<script src="js/pintuer.js"></script>
 </head>
 <style type="text/css">
 .file {
    position: relative;
    display: inline-block;
    overflow: hidden;
    
     
    /*text-decoration: none;
    text-indent: 0;
    line-height: 20px;
     background: #D0EEFF;
    border: 1px solid #99D3F5;
    border-radius: 4px;
    padding: 4px 12px;*/
}
.file input {
    position: absolute;
    /*font-size: 100px;*/
    right: 0;
    top: 0;
    opacity: 0;
}
</style>
<script type="text/javascript">
	function selectImageDone(url, index){
		url=url.substr(url.lastIndexOf("\\")+1);
		var imgInput = document.getElementById("imgUrl2");
		if(index == 1){
			imgInput = document.getElementById("imgUrl1");
		}
		
		imgInput.value=url;
		imgInput.attributes["data-image"].nodeValue = "";
		dishform.encoding="multipart/form-data";
	}
</script>
  <%
  	Dao dao = new Dao();
  	List<Map<String,Object>>dishList = dao.getTableByid("dish", "1", null);
	
	String imageURL = "";
	String errFile = (String)request.getAttribute("errFile");
	if(errFile==null){
		errFile="";
	}
	
	String idstring = dao.fetchShopPost("1");
	String [] ids = idstring.split("-"); 
	
	String buttonStyle = "button bg-main icon-check-square-o";
	String buttonText = "提交";
	String buttonAbled = "";
	
%>
  <body>
	
  <div class="body-content">
    <form id="dishform" method="post" class="form-x" action="HandleFront" >   
      
    	<div class="form-group">
	        <div class="label" style="width:150px">
	          <label>首页海报图片一：</label>
	        </div>
	        <div class="field"> 
	        	<img src=<%="https://mall.weikedashi.net/front/file1.jpg?time="+System.currentTimeMillis() %> alt="" width="300" height="100" />       	
	        </div>
	      </div>

      <div class="form-group">
        <div class="label" style="width:150px">
          <label>修改海报图片一：</label>
        </div>
        
        <input type="text" id="imgUrl1" name="img1" class="input tips" style="width:25%; float:left;"  value="<%=imageURL%>" data-toggle="hover" data-place="right" data-image="<%=imageURL%>" />
		<a href="javascript:;" class="file button bg-blue margin-left" style="float:left;">选择图片
    		<input type="file" onchange="selectImageDone(this.value, 1);" name="file1">
		</a>
        <div class="tipss">图片大小不超过2M</div>
        <font color="red"><%=errFile %></font>
       
      </div>
      
      <div class="form-group">
        <div class="label" style="width:150px">
          <label >绑定商品：</label>
        </div>
        <div class="field">
          <select class="input w50" name="postdish1" size="1"/>
          <%
          	if(dishList!=null){
       			for(Map<String,Object> map : dishList){
       				String id = map.get("id").toString();
       				String name = map.get("name").toString();
           %>
			<option value="<%=id%>" <%=id.equals(ids[0])?"selected":"" %>><%=name%></option>
		<%}} %>
	  </select>
          <div class="tips"></div>
        </div>
      </div>
      
      <br/><br/><br/>
      <div class="form-group">
	        <div class="label" style="width:150px">
	          <label>首页海报图片二：</label>
	        </div>
	        <div class="field"> 
	        	<img src=<%="https://mall.weikedashi.net/front/file2.jpg?time="+System.currentTimeMillis() %> alt="" width="300" height="100" />       	
	        </div>
	      </div>

      <div class="form-group">
        <div class="label" style="width:150px">
          <label>修改海报图片二：</label>
        </div>
        
        <input type="text" id="imgUrl2" name="img2" class="input tips" style="width:25%; float:left;"  value="<%=imageURL%>" data-toggle="hover" data-place="right" data-image="<%=imageURL%>" />
		<a href="javascript:;" class="file button bg-blue margin-left" style="float:left;">选择图片
    		<input type="file" onchange="selectImageDone(this.value, 2);" name="file2">
		</a>
        <div class="tipss">图片大小不超过2M</div>
        <font color="red"><%=errFile %></font>
       
      </div>
      
      <div class="form-group">
        <div class="label" style="width:150px">
          <label >绑定商品：</label>
        </div>
        <div class="field">
          <select class="input w50" name="postdish2" size="1"/>
          <%
          	if(dishList!=null){
       			for(Map<String,Object> map : dishList){
       				String id = map.get("id").toString();
       				String name = map.get("name").toString();
           %>
			<option value="<%=id%>" <%=id.equals(ids[1])?"selected":"" %>><%=name%></option>
		<%}} %>
	  </select>
          <div class="tips"></div>
        </div>
      </div>
      
    
      <div class="form-group">
        <div class="label" style="width:150px">
          <label></label>
        </div>
        <div class="field">
          <button class="<%=buttonStyle %>" type="submit" <%=buttonAbled %>> <%=buttonText %></button>
        </div>
      </div>
    </form>
  </div>    

  </body>
</html>
